import request from '../../utils/request';

// 优惠券管理相关 API

// 更新优惠券
export const updateCoupon = (data: any) => {
    return request({
        url: '/member/api/coupon',
        method: 'put',
        data
    });
};

// 创建优惠券
export const createCoupon = (data: any) => {
    return request({
        url: '/member/api/coupon',
        method: 'post',
        data
    });
};

// 根据ID获取优惠券
export const getCouponById = (id: string) => {
    return request({
        url: `/member/api/coupon/${id}`,
        method: 'get'
    });
};

// 删除优惠券
export const deleteCoupon = (id: string) => {
    return request({
        url: `/member/api/coupon/${id}`,
        method: 'delete'
    });
};

// 更新优惠券状态
export const updateCouponStatus = (id: string, status: string) => {
    return request({
        url: `/member/api/coupon/${id}/status/${status}`,
        method: 'put'
    });
};

// 获取所有启用的优惠券
export const getEnabledCoupons = () => {
    return request({
        url: '/member/api/coupon/enabled',
        method: 'get'
    });
};

// 分页查询优惠券
export const getCouponPage = (params: any) => {
    return request({
        url: '/member/api/coupon/page',
        method: 'get',
        params
    });
};
